;-------------------------------------------------------------------------------
; Mad Mix Music Compilation v1.z
;-------------------------------------------------------------------------------
; 25/01/2008 -> July 2009 by Megachur
;-------------------------------------------------------------------------------
begin_menu		equ &1000
screen_first_address	equ &c000
screen_crtc_address	equ &3000
screen_width		equ 96
USE_COMPACTER		equ 1
PACK_ADDRESS		equ &8000
; ---------------------------
LIST
; ---------------------------
	org begin_menu
; ---------------------------
NOLIST
; ---------------------------
WINAPE_SAVE equ 1

	IF WINAPE_SAVE

	write direct "a:MADMIXPL.",start

	ELSE

	run start

	ENDIF
; ---------------------------
.start
; ---------------------------
	call wait_vbl
	di

	ld hl,&0038
	ld (hl),&c3
	inc hl
	ld (hl),interrupt
	inc hl
	ld (hl),interrupt/&100

	xor a
	ld (current_music_enable_play),a

	call lbca7

	call init_scan_keyboard

	ld bc,&7f8e
;	ld bc,&7f8d
	out (c),c
	xor a
	out (c),a
	ld c,&54
	out (c),c
	inc a
	out (c),a
	out (c),c
	ld a,&10
	out (c),a
	out (c),c

	call set_crtc_regs

	ld a,(#be7d)			; adresses variables amsdos lecteur courant
	call Set_Drive_Number		; to tell which drive to use
	add a,65
	ld (music_insert_disk_drive_text),a
	xor a
	call Set_Drive_Head_Number

	ld sp,&0

	ld hl,screen_first_address
	ld de,screen_first_address+1
	ld bc,&3fff
	ld (hl),&00
	ldir

	ld bc,&7f01
	out (c),c
	ld a,&4b
	out (c),a

	ei

	ld hl,Intro_Text_Data
	call PRINT_TEXT

wait_intro_key
	call wait_vbl

	ld a,(keyboard_a_key_pressed)
	or a
	jr z,wait_intro_key	; no key pressed ?

	ld hl,screen_first_address
	ld de,screen_first_address+1
	ld bc,&3fff
	ld (hl),&00
	ldir

	call wait_vbl

	ld hl,text_intro
	call PRINT_TEXT

	ld hl,Spectrum_Analyzer_text
	call PRINT_TEXT

	call navigation_menu

loop
	call wait_vbl

	ld a,(keyboard_a_key_pressed)
	or a
	jr z,loop	; no key pressed ?

first_loop_tempo equ $+1
	ld a,5
	dec a
	ld (first_loop_tempo),a
	jr nz,loop
	ld a,5
	ld (first_loop_tempo),a

	ld a,(keyboard_line_press+keyboard_line_0)
	bit key_up,a
	jr z,not_key_up
	call navigation_menu_up
	jr loop
not_key_up
	bit key_down,a
	jr z,not_key_down
	call navigation_menu_down
	jr loop

not_key_down
	ld a,(keyboard_line_press+keyboard_line_5)
	bit key_space,a
	jr z,loop

validate_file
	xor a
	ld (fa19),a

load_current_music_selected_ok
	call load_current_music_selected

load_current_music_selected_not_needed
	ld a,(load_error_value)
	cp &ff
	jr z,loop
	or a
	jr nz,load_current_music_selected_ok

playing_current_music_theme
	ld a,(current_music_theme)
	ld (init_theme_number),a
	ld hl,0
	ld (time_counter_value),hl
	ld (time_counter_value+2),hl
;
; init current music
;
	xor a
	ld (fa19),a

	call wait_vbl

init_theme_number equ $ +1
	ld a,0
	di
	call init_music
	ei

	ld hl,music_playing_text
	CALL PRINT_TEXT
	ld a,(init_theme_number)
	ld (Number_To_Print),a
	call PRINT_NUMBER

	ld a,1
	ld (current_music_enable_play),a
;
play_music_wait_vbl
;
	call wait_vbl

	ld a,(l005b37)
	or a
	call nz,do_digit

	ld a,(fa19)
	cp 2
	jr nc,order_to_stop_music

	call draw_spectrum_analyzer

	ld de,(screen_address)
	call draw_time_counter
	ld (screen_address),de

	jr play_music_wait_vbl

order_to_stop_music
	xor a
	ld (current_music_enable_play),a

	call lbca7

	call PRINT_LINE_BLANK

	ld a,(fa19)

	cp 2
	jr z,play_next_theme

	cp 3
	jr z,play_previous_theme

	cp 4
	jp z,loop

;	cp 5
;	jr z,loop

; ---------------------------
play_next_file
; ---------------------------
	call navigation_menu_down
	jp validate_file
; ---------------------------
play_previous_theme
; ---------------------------
	ld a,(current_music_max_theme)
	ld c,a
	ld a,(current_music_theme)
	dec a
	or a
	jr z,playing_current_music_theme
	ld (current_music_theme),a
	jp playing_current_music_theme
; ---------------------------
play_next_theme
; ---------------------------
	ld a,(current_music_max_theme)
	inc a
	ld c,a
	ld a,(current_music_theme)
	inc a
	cp c
	jr nc,play_next_file
	ld (current_music_theme),a
	jp playing_current_music_theme
; ---------------------------
.actual_sound_level
; ---------------------------
	ld b,&00

	ld hl,screen_width*08+screen_first_address
	ld a,(psg_send_data_reg8)
	call draw_actual_sound_level
	ld hl,screen_width*09+screen_first_address
	ld a,(psg_send_data_reg9)
	call draw_actual_sound_level
	ld hl,screen_width*10+screen_first_address
	ld a,(psg_send_data_rega)

draw_actual_sound_level

	and &0f

	ld c,&10-1

	or a
	jr z,loop_clear

	cp c
	jr c,carry_10
	jr z,carry_10
carry_10
	dec b
loop_draw
	ld (hl),b
	inc hl
	dec c
	dec a
	jr nz,loop_draw
	inc b
loop_clear
	ld (hl),b
	inc hl
	dec c
	jp p,loop_clear

	ret
; ---------------------------
load_current_music_selected
; ---------------------------
	ld hl,loading_text
	call PRINT_TEXT

	ld hl,(current_file_load)
	ld a,(hl)
	inc hl
	add a,48
	ld (music_insert_disk_number_text),a	; set disk of current file

	IF USE_COMPACTER

	ld de,PACK_ADDRESS
	call OPEN_FILE

	ld a,(load_error_value)
	or a
	jr nz,load_current_music_selected_nodepack

	ld hl,decrunching_text
	call PRINT_TEXT

	ld hl,PACK_ADDRESS
	ld de,music_data

	call depack

load_current_music_selected_nodepack
	ELSE

	ld de,music_data
	call OPEN_FILE

	ENDIF

	jp PRINT_LINE_BLANK
; ---------------------------
.navigation_menu_up
; ---------------------------
; previous music !
; ---------------------------
	ld hl,(current_menu_item)
	ld a,h
	cp Musics_List_Alphabetical_Order/&100
	jr nz,not_first_menu_item
	ld a,l
	cp Musics_List_Alphabetical_Order
	jr nz,not_first_menu_item
	ld hl,Musics_List_Alphabetical_Order_end
	jr navigation_menu_print_filename

not_first_menu_item
	dec hl
	dec hl

	jr navigation_menu_print_filename
; ---------------------------
.navigation_menu_down
; ---------------------------
; next music !
; ---------------------------
	ld hl,(current_menu_item)
	ld a,h
	cp Musics_List_Alphabetical_Order_end/&100
	jr nz,not_last_menu_item
	ld a,l
	cp Musics_List_Alphabetical_Order_end
	jr nz,not_last_menu_item
	ld hl,Musics_List_Alphabetical_Order
	jr navigation_menu_print_filename

not_last_menu_item
	inc hl
	inc hl

navigation_menu_print_filename
	ld (current_menu_item),hl

	ld a,11		; menu_up_text
	call PRINT_CHAR
;	jp navigation_menu
; ---------------------------
.navigation_menu
; ---------------------------
	call PRINT_LINE_BLANK
	ld hl,game_name_text
	call PRINT_TEXT

	ld hl,(current_menu_item)
	ld e,(hl)
	inc hl
	ld d,(hl)
	ex de,hl
	ld a,(hl)
	inc hl
	push hl
	ld de,12
	ld b,0
	call mulu_16bx8b
	ld de,file_list
	add hl,de
	ld (current_file_load),hl
	pop hl
	ld a,(hl)
	inc hl
	ld (current_music_first_theme),a
	ld a,(hl)
	inc hl
	ld (current_music_max_theme),a
	ld (current_music_name),hl
	call PRINT_TEXT

	ld a,(hl)
	ld hl,music_author_text_Jochen_Hippel
	or a
	jr z,print_text_music_author
	ld hl,music_author_text_AnCool
	dec a
	jr z,print_text_music_author
	ld hl,music_author_text_Lap
	dec a
	jr z,print_text_music_author
	ld hl,music_author_text_Unknown
print_text_music_author
	call PRINT_TEXT

	ld hl,text_cr
	jp PRINT_TEXT
; ---------------------------
.draw_spectrum_analyzer
; ---------------------------
	call draw_freq_spectrum_analyzer

	ld a,03
	ld (draw_freq_pixel),a

	ld hl,(psg_send_data_reg0)
	ld a,(psg_send_data_reg8)

	call calculate_freq_spectrum_analyzer

	ld a,24
	ld (draw_freq_pixel),a

	ld hl,(psg_send_data_reg2)
	ld a,(psg_send_data_reg9)

	call calculate_freq_spectrum_analyzer

	ld a,192
	ld (draw_freq_pixel),a

	ld hl,(psg_send_data_reg4)
	ld a,(psg_send_data_rega)

calculate_freq_spectrum_analyzer
	cp &10
	jr nz,not_use_psg_preset
	ld a,&0f

not_use_psg_preset
	and &0f
	ret z
	ld (psg_channel_volume),a

	ld b,0

	ld a,h
	cp MAX_FREQUENCY/&100+1
	jr nc,psg_send_data_reg0_overflow_correction
	cp MAX_FREQUENCY/&100
	jr z,psg_send_data_reg0_overflow
	or a
	jr nz,psg_send_data_reg0_not_zero
	ld a,l

psg_send_data_reg0_fd
	cp &fd
	jr nc,psg_send_data_reg0_not_zero
	
	or a
	jr z,find_frequency_end
	jr find_frequency

psg_send_data_reg0_overflow
	ld a,l
	cp MAX_FREQUENCY
	jr c,psg_send_data_reg0_fd

psg_send_data_reg0_overflow_correction
	ld h,&07
	ld a,l
	and &77
	ld l,a

psg_send_data_reg0_not_zero
	srl h
	rr l
	inc b

	ld a,h
	or a
	jr nz,psg_send_data_reg0_not_zero
	ld a,l
	cp &fd
	jr nc,psg_send_data_reg0_not_zero

	or a
	jr z,find_frequency_end

find_frequency
	cp &0f
	jr c,find_frequency_end
	srl a
	inc b
	cp &0f
	jr c,find_frequency_end
	srl a
	inc b
	cp &0f
	jr c,find_frequency_end
	srl a
	inc b
	cp &0f
	jr c,find_frequency_end
	srl a
	inc b
	cp &0f
	jr c,find_frequency_end
frequency_zero
	xor a		; a = 0
find_frequency_end
	ld hl,frequence_table_analyzer_value
	ld c,a
	ld a,b		; a = octave
	ld b,&00
	ld d,b
	add hl,bc

	ld e,(hl)	; frequency value

	ld c,a		; c = octave
	sla c

draw_spectrum_analyzer_address equ $+1
	ld hl,draw_spectrum_analyzer_first_address_table
	add hl,bc
	ld a,(hl)
	inc hl
	ld h,(hl)
	ld l,a		; hl = screen_address

	add hl,de	; add pos_x

psg_channel_volume equ $ +1
	ld a,0		; <> 0

	ld c,&0f

	cp c
;	jr c,draw_freq_column_carry_10
	jr z,draw_freq_column_carry_10
	dec a
draw_freq_column_carry_10
	ld d,a

draw_freq_pixel equ $+1
	ld b,&aa

draw_freq_column
	ld a,(hl)
	or b
	ld (hl),a

	ld a,h
	sub &08
	ld h,a
	and &38
	cp &38
	jr nz,draw_freq_column_continue
	ld a,h
	add &40
	ld h,a
	ld a,l
	sub screen_width
	ld l,a
	jr nc,draw_freq_column_continue
	ld a,h
	dec h
	and &07
	jr nz,draw_freq_column_continue
	ld a,h
	add &08
	ld h,a

draw_freq_column_continue
	dec c
	dec d
	jp p,draw_freq_column

erase_freq_column
	ld a,(hl)
	and b
	ret z
	xor b
	ld (hl),a

erase_freq_column_no
	ld a,h
	sub &08
	ld h,a
	and &38
	cp &38
	jr nz,erase_freq_column_continue
	ld a,h
	add &40
	ld h,a
	ld a,l
	sub screen_width
	ld l,a
	jr nc,erase_freq_column_continue
	ld a,h
	dec h
	and &07
	jr nz,erase_freq_column_continue
	ld a,h
	add &08
	ld h,a

erase_freq_column_continue
	dec c
	jp p,erase_freq_column

	ret
; ---------------------------
draw_freq_spectrum_analyzer
; ---------------------------
	ld hl,draw_spectrum_analyzer_first_address-&0800
	ld de,draw_spectrum_analyzer_first_address
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-&1000+95/&100
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-&1800/&100
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-&2000+95/&100
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-&2800/&100
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-&3000+95/&100
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-&3800/&100
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld hl,draw_spectrum_analyzer_first_address-screen_width+95
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld h,draw_spectrum_analyzer_first_address-screen_width-&0800/&100
	ld de,draw_spectrum_analyzer_first_address-screen_width
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-screen_width-&1000+95/&100
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-screen_width-&1800/&100
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-screen_width-&2000+95/&100
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-screen_width-&2800/&100
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-screen_width-&3000+95/&100
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld h,draw_spectrum_analyzer_first_address-screen_width-&3800/&100
	ld bc,96-1
	ldir
	ld a,(hl)
	ld (de),a
	ld d,h
	ld e,l
	ld hl,draw_spectrum_analyzer_first_address-screen_width-screen_width+95
	ld bc,96-1
	lddr
	ld a,(hl)
	ld (de),a
	ret
; ---------------------------
;.make_filename
; In
;	de = name of music ptr
; Out
;	de = name of music ptr
; ---------------------------
;	push de
;	push hl
;	push de
;	xor a
;	ld (make_filename_spaces_in_game_name),a
;	ld (make_filename_count_of_character_in_game_name),a
;	ld (make_filename_count_character),a

;make_filename_count_of_spaces_in_game_name
;make_filename_count_of_character_in_game_name equ $ +1
;	ld a,0
;	inc a
;	ld (make_filename_count_of_character_in_game_name),a
;make_filename_continue_to_count
;	ld a,(de)
;	inc de
;	cp " "
;	jr nz,make_filename_not_space_in_game_name
;make_filename_spaces_in_game_name equ $ +1
;	ld a,0
;	inc a
;	ld (make_filename_spaces_in_game_name),a
;	jr make_filename_count_of_spaces_in_game_name
;make_filename_not_space_in_game_name
;	or a
;	jr nz,make_filename_count_of_spaces_in_game_name
;
;;	pop hl	; hl = name of music ptr
;	ld de,current_music_filename
;
;make_filename_begin
;	ld a,(hl)
;	or a
;	jr z,make_filename_complete
;	ld a,(make_filename_count_character)
;	ld b,a
;	ld a,8
;	sub b
;	ld b,a	; b = character left
;	ld a,(make_filename_spaces_in_game_name)
;	sub b
;	jr c,make_filename_begin_continue
;	or a
;	jr z,make_filename_begin_continue
;make_filename_begin_delete_character
;	dec de
;	ld b,a
;	ld a,(make_filename_count_character)
;	dec a
;	ld (make_filename_count_character),a
;	ld a,b
;	dec a
;	or a
;	jr nz,make_filename_begin_delete_character
;make_filename_begin_continue
;	ld a,(hl)
;	cp " "
;	jr nz,make_filename_fill
;	inc hl
;	ld a,(make_filename_spaces_in_game_name)
;	dec a
; 	ld (make_filename_spaces_in_game_name),a
;make_filename_fill
;	ld a,(make_filename_count_character)
;	cp 8
;	jr z,make_filename_end
;	inc a
;	ld (make_filename_count_character),a
;make_filename_fill_one_char
;	ld a,(hl)
;	ld (de),a
;	inc de
;	inc hl
;	jr make_filename_begin

;make_filename_complete
;make_filename_count_character equ $ +1
;	ld a,0
;	cp 8
;	jr z,make_filename_end
;	inc a
;	ld (make_filename_count_character),a
;	ld a," "
;	ld (de),a
;	inc de
;	jr make_filename_complete 
;
;make_filename_end	
;	pop hl
;	pop de
;	ret
;-------------------------------------------------------------------------------
.OPEN_FILE
;-------------------------------------------------------------------------------
; In
;	hl = Filename Ptr
;	de = Buffer Address
; ---------------------------
; Out
; a = Return State
;	0 -> File Loaded
;	1 -> Disc Missing
;	2 -> Read Fail
;	3 -> File Not Found
; ---------------------------
	xor a
	ld (load_error_value),a

	ld b,d
	ld c,e

	call LOADFILE

;
.chek_Load_Error
;
	ld (load_error_value),a

	or a
	jp z,Set_Motor_Off	; end loading with no error

	cp 1
	jr z,load_error_file_missing

	cp 3
	jr z,load_error_file_missing

	ld a,FDC_Command_Recalibrate
	call FDC_Command

	jr error_load_wait_return_text

load_error_file_missing
;
; Try the other head of the drive if drive is two side
;
	ld a,(Disk_Drive_Two_Side)
	or a
	jr nz,error_load_wait_return_text

	ld a,(HDSDS1DS0)
	and 4
	xor 4
	sra a
	sra a

	push af

	call Set_Drive_Head_Number	; to tell which drive to use, head to read.

	pop af
	add a,48
	ld (music_insert_disk_drive_head_text),a

error_load_wait_return_text
	ld hl,text_cr
	call PRINT_TEXT

error_load_wait
error_load_wait_number  equ $+1
	ld a,0
	inc a
	ld (error_load_wait_number),a
	cp &10
	jr nz,error_load_wait_keys
	xor a
	ld (error_load_wait_number),a

error_load_wait_text_swap equ $+1
	ld a,0
	xor 1
	ld (error_load_wait_text_swap),a
	or a
	jr nz,error_load_print_blank_line

error_load_wait_retry	equ $+1
	ld a,0
	inc a
	ld (error_load_wait_retry),a
	cp &10/2
	jr z,error_load_end

	ld hl,music_insert_disk_text
	call PRINT_TEXT
	jr error_load_wait_keys

error_load_print_blank_line
	call PRINT_LINE_BLANK

error_load_wait_keys
	call wait_vbl

;	call scan_keyboard

	ld a,(keyboard_a_key_pressed)
	or a
	jr z,error_load_wait

	ld a,(keyboard_line_press+keyboard_line_8)
	bit key_esc,a
	jr nz,error_load_stop

	bit key_a,a
	jr z,error_load_not_key_a

	xor a

	jr error_load_change_drive

error_load_not_key_a
	ld a,(keyboard_line_press+keyboard_line_6)
	bit key_b,a
	jr z,error_load_end

	ld a,1

error_load_change_drive
	call Set_Drive_Number	; Drive A or B

	add a,65
	ld (music_insert_disk_drive_text),a

	jr error_load_end

error_load_stop
	ld a,&ff
	ld (load_error_value),a

error_load_end
	call PRINT_LINE_BLANK

	xor a
	ld (error_load_wait_retry),a
	ld (error_load_wait_number),a

;	ld a,11
;	call PRINT_CHAR

	jp Set_Motor_Off
;
load_error_value
	db 0
;-------------------------------------------------------------------------------
.interrupt
;-------------------------------------------------------------------------------
	di
	push af
	push bc
	push de
	push hl
	push ix
	push iy

	ld hl,interrupt_next_counter+1

	ld b,&f5
	in a,(c)
	rra
	jr nc,interrupt_next
	ld (hl),&0
	jr interrupt_next_counter
interrupt_next
	defs 2,0
	inc (hl)
interrupt_next_counter
	ld a,&ff
	cp 6
	jr c,interrupt_next_bad_crtc
	xor a
interrupt_next_bad_crtc
	ld (hl),a

	ld hl,interrupt_list
	ld b,&00
	add a,a
	ld c,a
	add hl,bc
	ld e,(hl)
	inc hl
	ld d,(hl)
	ex de,hl
	jp (hl)
interrupt_list
	dw first_interrupt
	dw interrupt_Sense_Interrupt
	dw third_interrupt
	dw interrupt_back
	dw interrupt_back
	dw interrupt_back

.first_interrupt
	call scan_keyboard

	ld a,(current_music_enable_play)
	or a
	jp z,interrupt_back

	call play_music

	call actual_sound_level

	ld a,(l005b38)
	or a
	jr nz,music_end_detected

;.test_keyboard_interrupt_back

	ld a,(keyboard_a_key_pressed)
	or a
	jp z,interrupt_back	; no key pressed

first_interrupt_tempo equ $+1
	ld a,5
	dec a
	ld (first_interrupt_tempo),a
	jr nz,interrupt_back

	ld a,5
	ld (first_interrupt_tempo),a

	ld a,(keyboard_line_press+keyboard_line_8)
	bit key_esc,a
	jr z,interrupt_test_key_left

	ld a,4
	jr clean_music_end_detected

interrupt_test_key_left

	ld a,(keyboard_line_press+keyboard_line_1)
	bit key_left,a
	jr z,interrupt_test_key_right

	ld a,3
	jr clean_music_end_detected

interrupt_test_key_right
	ld a,(keyboard_line_press+keyboard_line_0)
	bit key_right,a
	jr nz,music_end_detected

interrupt_test_key_space
	ld a,(keyboard_line_press+keyboard_line_5)
	bit key_space,a
	jr z,interrupt_back

	ld a,5
	jr clean_music_end_detected

music_end_detected
	xor a
	ld (l005b38),a

	ld a,2

clean_music_end_detected
	ld (fa19),a

	jr interrupt_back

.interrupt_Sense_Interrupt

	call Sense_Interrupt
;	cp 3
;	jr nz,interrupt_back
;	xor a
;	ld (Sense_Interrupt_Active),a	; stop interrupt

;	ld hl,(screen_address)
;	ld (Sense_save_screen_address),hl
;	ld hl,screen_width*1+&4c+screen_first_address
;	ld (screen_address),hl

;	ld a,(FDC_Result_ST0)
;	ld (Hexa_Number_To_Print),a
;	call PRINT_HEXA_NUMBER

;Sense_save_screen_address equ $ +1
;	ld hl,0
;	ld (screen_address),hl

	jr interrupt_back

.third_interrupt
	call time_counter

interrupt_back
	pop iy
	pop ix
	pop hl
	pop de
	pop bc
	pop af
	ei
	reti
;-------------------------------------------------------------------------------
; Print Manager
;-------------------------------------------------------------------------------
	read "..\Common_Sources\Print_Manager_v1_1.asm"
;-------------------------------------------------------------------------------
; CRTC Manager
;-------------------------------------------------------------------------------
	read "..\Common_Sources\CRTC_Manager_v1_0.asm"
	read "MadMix_menu_CRTC_data_v1_0.asm"
;-------------------------------------------------------------------------------
; Ay Sound Manager
;-------------------------------------------------------------------------------
	read "..\Common_Sources\Ay_Sound_Manager_v1_0.asm"
;-------------------------------------------------------------------------------
; Keyboard Manager
;-------------------------------------------------------------------------------
	read "..\Common_Sources\Keyboard_Manager_v1_0.asm"
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
	IF USE_COMPACTER

	read "..\Common_Sources\Bitbuste_1_2_DeComp_v1_0.asm"

	ENDIF
;-------------------------------------------------------------------------------
; Menu text data
;-------------------------------------------------------------------------------
	read "Madmix_menu_text_data_v1_2.asm"
;-------------------------------------------------------------------------------
; Music data
;-------------------------------------------------------------------------------
	read "Madmix_menu_data_v1_2.asm"
;-------------------------------------------------------------------------------
; Time Counter
;-------------------------------------------------------------------------------
	read "..\Common_Sources\Time_Counter_v1_0.asm"
;-------------------------------------------------------------------------------
; FDC Read
;-------------------------------------------------------------------------------
	read "..\Common_Sources\FDC_v2_e.asm"
;-------------------------------------------------------------------------------
; Music Player
;-------------------------------------------------------------------------------
	read "MadMix_music_player_v1_5_z80.asm"
;-------------------------------------------------------------------------------
; Intro text (free memory)
;-------------------------------------------------------------------------------
	read "MadMix_intro_text_data_v1_0.asm"
;-------------------------------------------------------------------------------
; End Of File
;-------------------------------------------------------------------------------
EOF_ADDRESS
LIST
EOF_LENGTH equ EOF_ADDRESS-begin_menu
NOLIST
CLOSE
